<?php


class Categorie extends Admin_Controller {
		public function __construct(){ 
			parent::__construct(); 	
			$this->load->helper("url");
			
		}
	
		public function index() {
			$this->load->helper("menu");
			$this->_data['titlePage']= "CATEGORIES";						// title 
			$this->_data['loadPage']="user/cate_view";						//link to cate_view.php = noi dung chinh
			$this->load->model('Mcategorie');							
			$this->_data['info']= $this->Mcategorie->listAllcate();
			$this->load->view($this->_data['path'],$this->_data);

		}	
		
		public function del(){
			$id = $this->uri->segment(4);									// id cua danh muc 
			$this->load->model('Mcategorie');
			$this->Mcategorie->deleteUser($id);
			redirect (base_url().'admin/categorie/index');
		
		}

		public function add(){
			$name= $this->input->post("name");				// name = na in jquery code ,(name="+na+"&cate="+ca,)
			$pa = $this->input->post("cat");				// cate= cal in jquery code
				if ($name != ""){ 
			$data= array(
			 		"cate_title" => $name,	
			 		"cate_parent" => $pa 	
			); 
			$this->load->model("Mcategorie"); 	
			$this->Mcategorie->addcate($data);
				echo "ADD CATEGORIE DA THANH CONG ";
		 		}else{										// $name= "" : nguoi dung chua dang nhap ten 
		 			echo "1"; 		

		 		}	
		
		}	// end of add function 



		
}// end class

?>